package com.hnust.api;

import com.github.lianjiatech.retrofit.spring.boot.annotation.RetrofitClient;
import com.hnust.domain.BulkImport;
import com.hnust.domain.ChapterData;
import com.hnust.domain.ChapterDataRecord;
import com.hnust.domain.Result;
import feign.Response;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author: Yjx
 * @Data: 2021/10/27 17:53
 * @Version 1.0
 * @Project_Name: testTeacher
 * @describe
 */
@FeignClient(
        name = "ChapterApi",
        url = "${feign.baseUrl}",
        configuration = SubjectApis.MultipartSupportConfig.class)
public interface ChapterApi {
    @GetMapping("/download/chapter")
    Response getTem();

    @PostMapping(value="/upload/Chapter",
            headers = {"Content-Type="+ MediaType.MULTIPART_FORM_DATA_VALUE})
    Result<List<ChapterData>> upload(@RequestPart("file") MultipartFile file,
                                     @RequestParam("courseId") String courseId);

    @PostMapping(value = "/chapter/allImport",headers = {"Content-Type="+MediaType.APPLICATION_JSON_VALUE})
    Result<String> allImport(@RequestBody ChapterDataRecord data,@RequestParam("courseId") String courseId);
}
